The weight of domains created with xm created can be specified with "weight=x" command line option, or put into the config file. Specific scheduler is responsible for handling this additional information. RRobin and Atropos ignore the argument.
# Which CPU to start domain on?
#cpu = -1 # leave to Xen to pick
+# The weight (CPU share) of the domain. Works with all
+# schedulers that have notion of weight (eg BVT).
+# Default is 1. Float values can be used.
+#weight = 1.5
#----------------------------------------------------------------------------
# Define network interfaces.
# Which CPU to start domain on?
#cpu = -1 # leave to Xen to pick
cpu = vmid # set based on vmid (mod number of CPUs)
+# The weight (CPU share) of the domain. Works with all
+# schedulers that have notion of weight (eg BVT).
+# Default is 1. Float values can be used.
+#weight = 1.5
#----------------------------------------------------------------------------
# Define network interfaces.
unsigned int mem_kb,
const char *name,
int cpu,
+ float weight,
u32 *pdomid);
int xc_domain_pause(int xc_handle,
u32 domid);
unsigned int mem_kb,
const char *name,
int cpu,
+ float weight,
u32 *pdomid)
{
int err;
op.cmd = DOM0_CREATEDOMAIN;
op.u.createdomain.domain = (domid_t)*pdomid;
op.u.createdomain.memory_kb = mem_kb;
+ /* The weight of a domain added to the domain creation code */
+ op.u.createdomain.weight = weight;
strncpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
op.u.createdomain.name[MAX_DOMAIN_NAME-1] = '\0';
op.u.createdomain.cpu = cpu;
unsigned int mem_kb = 0;
char *name = "(anon)";
int cpu = -1;
+ float weight;
u32 dom = 0;
int ret;
- static char *kwd_list[] = { "dom", "mem_kb", "name", "cpu", NULL };
+ static char *kwd_list[] = { "dom", "mem_kb", "name", "cpu", "weight",
+ NULL };
- if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisi", kwd_list,
- &dom, &mem_kb, &name, &cpu) )
+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iisif", kwd_list,
+ &dom, &mem_kb, &name, &cpu, &weight) )
return NULL;
-
- if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 )
+
+ if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu,
+ weight, &dom)) < 0 )
return PyErr_SetFromErrno(xc_error);
return PyInt_FromLong(dom);
self.config = config
try:
self.name = sxp.child_value(config, 'name')
+ self.weight = float(sxp.child_value(config, 'weight'))
self.check_name(self.name)
self.memory = int(sxp.child_value(config, 'memory'))
if self.memory is None:
if self.recreate: return
memory = self.memory
name = self.name
+ weight = self.weight
cpu = int(sxp.child_value(self.config, 'cpu', '-1'))
dom = self.dom or 0
- dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu)
+ dom = xc.domain_create(dom= dom, mem_kb= memory * 1024, name= name, cpu= cpu, weight= weight)
if dom <= 0:
raise VmError('Creating domain failed: name=%s memory=%d'
% (name, memory))
add_config_handler('name', vm_field_ignore)
add_config_handler('memory', vm_field_ignore)
add_config_handler('cpu', vm_field_ignore)
+add_config_handler('weight', vm_field_ignore)
add_config_handler('console', vm_field_ignore)
add_config_handler('image', vm_field_ignore)
add_config_handler('device', vm_field_ignore)
fn=set_value, default=128,
use="Domain memory in MB.")
+gopts.var('weight', val='WEIGHT',
+ fn=set_value, default=1,
+ use="Domain cpu weight (default=1).")
+
gopts.var('console', val='PORT',
fn=set_int, default=None,
use="Console port to use. Default is 9600 + domain id.")
config = ['vm',
['name', vals.name ],
- ['memory', vals.memory ] ]
+ ['memory', vals.memory ],
+ ['weight', vals.weight] ]
if vals.cpu:
config.append(['cpu', vals.cpu])
if vals.blkif:
cpu = ++cpucount;
- if ( (idle = do_createdomain(IDLE_DOMAIN_ID, cpu)) == NULL )
+ if ( (idle = do_createdomain(IDLE_DOMAIN_ID, cpu, 0)) == NULL )
panic("failed 'createdomain' for CPU %d", cpu);
set_bit(DF_IDLETASK, &idle->flags);
pro = op->u.createdomain.cpu % smp_num_cpus;
ret = -ENOMEM;
- if ( (d = do_createdomain(dom, pro)) == NULL )
+ if ( (d = do_createdomain(dom, pro, op->u.createdomain.weight))==NULL)
break;
-
+
if ( op->u.createdomain.name[0] )
{
strncpy(d->name, op->u.createdomain.name, MAX_DOMAIN_NAME);
struct domain *task_hash[TASK_HASH_SIZE];
struct domain *task_list;
-struct domain *do_createdomain(domid_t dom_id, unsigned int cpu)
+struct domain *do_createdomain(domid_t dom_id, unsigned int cpu, float weight)
{
char buf[100];
struct domain *d, **pd;
spin_lock_init(&d->pcidev_lock);
INIT_LIST_HEAD(&d->pcidev_list);
- sched_add_domain(d);
+ sched_add_domain(d, weight);
write_lock_irqsave(&tasklist_lock, flags);
pd = &task_list; /* NB. task_list is maintained in order of dom_id. */
else
{
sprintf(d->name, "Idle-%d", cpu);
- sched_add_domain(d);
+ sched_add_domain(d, weight);
}
return d;
task_hash[TASK_HASH(IDLE_DOMAIN_ID)] = &idle0_task;
/* Create initial domain 0. */
- new_dom = do_createdomain(0, 0);
+ new_dom = do_createdomain(0, 0, 1);
if ( new_dom == NULL )
panic("Error creating domain 0\n");
* - they shouldn't be on any queue */
}
-/* prepare a task to be added to scheduling */
-static void at_add_task(struct domain *p)
+/* prepare a task to be added to scheduling
+ TODO - can weight argument can be used to set up the
+ scheduling parameters? */
+static void at_add_task(struct domain *p, float weight)
{
s_time_t now = NOW();
/*
* Add and remove a domain
*/
-void bvt_add_task(struct domain *p)
+void bvt_add_task(struct domain *p, float weight)
{
struct bvt_dom_info *inf = BVT_INFO(p);
ASSERT(inf != NULL);
ASSERT(p != NULL);
- inf->mcu_advance = MCU_ADVANCE;
+ if(weight > 0)
+ inf->mcu_advance = MCU_ADVANCE / weight;
+ else
+ inf->mcu_advance = MCU_ADVANCE;
inf->domain = p;
inf->warpback = 0;
/* Set some default values here. */
if(bvt_alloc_task(p) < 0) return -1;
- bvt_add_task(p);
+ bvt_add_task(p, 0);
spin_lock_irqsave(&CPU_INFO(p->processor)->run_lock, flags);
/*
* Add and remove a domain
*/
-void fbvt_add_task(struct domain *p)
+void fbvt_add_task(struct domain *p, float weight)
{
struct fbvt_dom_info *inf = FBVT_INFO(p);
ASSERT(inf != NULL);
ASSERT(p != NULL);
- inf->mcu_advance = MCU_ADVANCE;
+ if(weight > 0)
+ inf->mcu_advance = MCU_ADVANCE / weight;
+ else
+ inf->mcu_advance = MCU_ADVANCE;
inf->domain = p;
if ( p->domain == IDLE_DOMAIN_ID )
{
if(fbvt_alloc_task(p) < 0) return -1;
- fbvt_add_task(p);
+ fbvt_add_task(p, 0);
spin_lock_irqsave(&CPU_INFO(p->processor)->run_lock, flags);
set_bit(DF_RUNNING, &p->flags);
if ( !__task_on_runqueue(p) )
return 0;
}
-/* Setup the rr_dom_info */
-static void rr_add_task(struct domain *p)
+/* Setup the rr_dom_info
+ The weight argument is ignored as RRobin does not use weights */
+static void rr_add_task(struct domain *p, float weight)
{
struct rrobin_dom_info *inf;
RR_INFO(p)->domain = p;
{
unsigned long flags;
if(rr_alloc_task(p) < 0) return -1;
- rr_add_task(p);
+ rr_add_task(p, 0);
spin_lock_irqsave(&run_locks[p->processor], flags);
set_bit(DF_RUNNING, &p->flags);
/*
* Add and remove a domain
*/
-void sched_add_domain(struct domain *d)
+void sched_add_domain(struct domain *d, float weight)
{
/* Must be unpaused by control software to start execution. */
set_bit(DF_CTRLPAUSE, &d->flags);
schedule_data[d->processor].idle = d;
}
- SCHED_OP(add_task, d);
+ SCHED_OP(add_task, d, weight);
TRACE_2D(TRC_SCHED_DOM_ADD, d->domain, d);
}
MEMORY_PADDING;
u8 name[MAX_DOMAIN_NAME]; /* 8 */
u32 cpu; /* 24 */
- u32 __pad0; /* 28 */
+ float weight; /* 28 */
/* IN/OUT parameters. */
/* If 0, domain is allocated. If non-zero use it unless in use. */
domid_t domain; /* 32 */
int (*init_scheduler) ();
int (*init_idle_task) (struct domain *);
int (*alloc_task) (struct domain *);
- void (*add_task) (struct domain *);
+ void (*add_task) (struct domain *, float weight);
void (*free_task) (struct domain *);
void (*rem_task) (struct domain *);
void (*sleep) (struct domain *);
}
extern struct domain *do_createdomain(
- domid_t dom_id, unsigned int cpu);
+ domid_t dom_id, unsigned int cpu, float weight);
extern int construct_dom0(struct domain *d,
unsigned long alloc_start,
unsigned long alloc_end,
#define set_current_state(_s) do { current->state = (_s); } while (0)
void scheduler_init(void);
void schedulers_start(void);
-void sched_add_domain(struct domain *d);
+void sched_add_domain(struct domain *d, float weight);
void sched_rem_domain(struct domain *d);
long sched_ctl(struct sched_ctl_cmd *);
long sched_adjdom(struct sched_adjdom_cmd *);